package com.cdream.basic.thread;

/**
 * @author cdream
 * @date 2020/11/15
 */
public class InterruptExample {
    /**
     * {@link InterruptedException} 抛出这个异常的方法表明这是一个线程阻塞方法,如果方法被中断，将努力结束阻塞状态
     */
    public void testInterrupt() {
        Thread.currentThread().interrupt();
        Runtime.getRuntime().availableProcessors();

    }

    public static void testUncatchHandler() {
        Thread thread = new Thread(() -> {
            throw new RuntimeException("让我瞅瞅");
        });
        thread.setUncaughtExceptionHandler(new LogHandler());
        thread.start();
    }

    public static void main(String[] args) {
        testUncatchHandler();
    }
}
